<?php
class UserAction extends CommonAction {
	public function index() {
		$User = M ( 'User' );
		import ( 'ORG.Util.Page' );
		$totalRows = $User->count ();
		$Page = new Page ( $totalRows, $this->listRows );
		$orderBy = 'user_register_time desc';
		if ($_POST) {
			$where = array (
					'user_email' => $this->_post ( 'user_email' ) 
			);
		} else if ($this->_get ( 'sort' )) {
			$orderBy = $this->_get ( 'sort' ) . ' desc';
		}
		$userList = $User->where ( $where )->limit ( $Page->firstRow . ',' . $Page->listRows )->order ( $orderBy )->select ();
		$this->assign ( 'pageShow', $Page->show () );
		$this->assign ( 'userList', $userList );
		$this->display ();
	}
	public function info() {
		$User = M ( 'User' );
		if ($_POST) {
			$_POST['user_advance_time'] = strtotime($_POST['user_advance_time']);
			$User->save ( $_POST );
			$this->redirect ( 'index' );
		}
		$this->assign ( 'userInfo', $User->where ( 'user_id = ' . $this->_get ( 'user_id' ) )->find () );
		$Keywords = M ( 'Keywords' );
		$this->assign ( 'userKeywords', $Keywords->where ( 'user_id = ' . $this->_get ( 'user_id' ) )->order ( 'add_time desc' )->select () );
		$this->display ();
	}
}